package com.wbsxch.secondkill.enums;

public enum  SecondKillStateEnum {
    SUCCESS(1,"秒杀成功"),
    END(0,"秒杀结束"),
    REPEAT_KILl(-1,"重复秒杀"),
    INNER_ERROR(-2,"系统异常"),
    DATA_REWRITE(-3,"数据篡改"),
    ;
    private int state;
    private String stateInfo;

    SecondKillStateEnum(int state, String stateInfo) {
        this.state = state;
        this.stateInfo = stateInfo;
    }

    public int getState() {
        return state;
    }

    public String getStateInfo() {
        return stateInfo;
    }

    public static SecondKillStateEnum stateOf(int index){
        for(SecondKillStateEnum secondKillStateEnum:values()){
            if(secondKillStateEnum.getState() == index){
                return secondKillStateEnum;
            }
        }
        return null;
    }
}
